﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GIFT_SHOP_MVC.Models.SanPham>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Detail
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Detail</h2>
        
        <div style="float:left;width:300px;height:300px;padding: 4px;border: 1px solid #2e202a;margin-bottom: 10px;">
            <img src="<%=Model.Hinh %>" alt="" width="300px" height="300px"/>
        </div>

        <div style="margin-left:350px; font-size:large ">
           <p>Name product: <%=Model.TenSanPham %><br /></p>
           <p>Views : <%=Model.SoLuotXem%><br /></p>
           <p>Sales : <%=Model.SL_Ban%><br /></p>
           <p>Price : <%=Model.Gia%><br /></p>
           <p>Description: <%=Model.MoTa%></p>
           <% if (Model.SL_Ton > 1)
              { %>
            <a href="../../Cart/AddCart/<%=Model.MaSanPham %>"> <img src="../../Content/images/buynow.png" alt="" /></a>
            <%} %>
           <br />
        </div > 
        <div style="margin-top:180px;width:100%;">

        <%
            GIFT_SHOP_MVC.Models.GiftShop_LinQDataContext data = new GIFT_SHOP_MVC.Models.GiftShop_LinQDataContext();
            var pro = data.SanPhams.Where(pr => pr.MaTheLoai == Model.MaTheLoai && pr.MaSanPham != Model.MaSanPham);         
            int sl = pro.Count(),s1,s2,s3;
            do
            {
                Random a = new Random();           
                s1=a.Next(0, sl - 1);
                s2=a.Next(0, sl - 1);
                s3=a.Next(0, sl - 1);
            }
            while (s1==s2 || s1==s3|| s2==s3 );
            var p1 = pro.Select(p => p).Skip(s1).Take(1);
            var p2 = pro.Select(p => p).Skip(s2).Take(1);
            var p3 = pro.Select(p => p).Skip(s3).Take(1);          
           %>

    <h2>Related Products</h2>
           <div class='product_box'>
            <h3><%Response.Write(p1.First().TenSanPham); %></h3>
                <div class="image_wrapper">
                    <a href="/Product/Detail/<%=p1.First().MaSanPham %>">
                        <% if (p1.First().SL_Ton < 0) Response.Write("<i style='margin-left:2px; background-image: url(../../Content/images/sold_out.png); width:190px; height:108px; position: absolute;'> </i>");  %>
                        <img src="<%=p1.First().Hinh%>" alt="" width="190px" height="108px" />
                    </a>
                </div>
                <p class="price">Price: <%=p1.First().Gia%></p>
                <center><% if (p1.First().SL_Ton > 0) Response.Write("<a href='/Cart/AddCart/" + p1.First().MaSanPham.ToString() + "'><img width='80' height='30' alt='' src='../../Content/images/buynow.png' /></a>");
                   else Response.Write("<img src='../../Content/images/blank.png' border='0' />"); %></center>
            </div>

            <div class='product_box'>
            <h3><%Response.Write(p2.First().TenSanPham); %></h3>
                <div class="image_wrapper">
                    <a href="/Product/Detail/<%=p2.First().MaSanPham %>">
                        <% if (p2.First().SL_Ton < 0) Response.Write("<i style='margin-left:2px; background-image: url(../../Content/images/sold_out.png); width:190px; height:108px; position: absolute;'> </i>");  %>
                        <img src="<%=p2.First().Hinh%>" alt="" width="190px" height="108px" />
                    </a> 
                </div>
                <p class="price">Price: <%=p2.First().Gia%></p>
                <center><% if (p2.First().SL_Ton > 0) Response.Write("<a href='/Cart/AddCart/" + p2.First().MaSanPham.ToString() + "'><img width='80' height='30' alt='' src='../../Content/images/buynow.png' /></a>");
                   else Response.Write("<img src='../../Content/images/blank.png' border='0' />"); %></center> 
            </div>

            <div class='product_box'>
            <h3><%Response.Write(p3.First().TenSanPham); %></h3>
                <div class="image_wrapper">
                    <a href="/Product/Detail/<%=p3.First().MaSanPham %>">
                        <% if (p3.First().SL_Ton < 0) Response.Write("<i style='margin-left:2px; background-image: url(../../Content/images/sold_out.png); width:190px; height:108px; position: absolute;'> </i>");  %>
                        <img src="<%=p3.First().Hinh%>" alt="" width="190px" height="108px" />
                    </a>
                </div>
                <p class="price">Price: <%=p3.First().Gia%></p>
                <center><% if (p3.First().SL_Ton > 0) Response.Write("<a href='/Cart/AddCart/" + p3.First().MaSanPham.ToString() + "'><img width='80' height='30' alt='' src='../../Content/images/buynow.png' /></a>");
                   else Response.Write("<img src='../../Content/images/blank.png' border='0' />"); %></center>
            </div>
        </div>

</asp:Content>
